package com.ydx.demo.mapper;

import com.ydx.demo.entity.Medicine;
import com.ydx.demo.entity.Order;
import com.ydx.demo.entity.Shopcart;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface OrderMapper {
    //查询所有订单
    @Select("select * from orders")
    List<Order> finOrdersAll();

    //结算商品到订单表
    @Insert("""
            INSERT INTO orders(drugId, name,code,number,odPrice)
            VALUES (#{drugId}, #{name},#{code},#{number},#{odPrice})
            """)
    @Options(useGeneratedKeys = true, keyProperty = "id")
    int insertOrders(Order order);

    //修改订单表的状态
    @Update("update orders set orderState = '已退单' where id = #{id}")
    void UpdateState(Order order);
}
